package com.example.demo.service.impl;

import com.example.demo.domain.SingleClause;
import com.example.demo.domain.exam.ExamUserAnswerOption;
import com.example.demo.mapper.ExamUserAnswerOptionMapper;
import com.example.demo.service.ExamUserAnswerOptionService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ExamUserAnswerOptionServiceImpl extends BaseServiceImpl<ExamUserAnswerOptionMapper, ExamUserAnswerOption> implements ExamUserAnswerOptionService {

    private final ExamUserAnswerOptionMapper mapper;

    @Override
    public void insertList(List<ExamUserAnswerOption> options) {
        if (CollectionUtils.isEmpty(options)) {
            return;
        }
        super.saveBatch(options);
    }

    @Override
    public void deleteByAnswerIds(List<Long> answerIds) {
        if (CollectionUtils.isEmpty(answerIds)){
            return;
        }
        super.delete(SingleClause.in("answer_id", answerIds.toArray(new Object[0])));
    }
}
